<!DOCTYPE html><html lang="zh-CN"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1"><meta name="format-detection" content="telephone=no"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><link rel="icon" href="/images/icons/IMG_1680(20230123-175413).JPG?v=2.8.0" type="image/png" sizes="16x16"><link rel="icon" href="/images/icons/IMG_1680(20230123-175413).JPG?v=2.8.0" type="image/png" sizes="32x32"><meta name="description" content="@RequestParam注解：       123456789@Controller@RequestMapping(&quot;&#x2F;vote&quot;)public class VoteHandler &amp;#123;   @RequestMapping(value &#x3D; &quot;&#x2F;test01&quot;)   public String test01(@">
<meta property="og:type" content="article">
<meta property="og:title" content="SpringMVC笔记">
<meta property="og:url" content="http://shuaidaia.gitee.io/2024/03/14/SpringMVC%E7%AC%94%E8%AE%B0/index.html">
<meta property="og:site_name" content="码农呆的奋斗史">
<meta property="og:description" content="@RequestParam注解：       123456789@Controller@RequestMapping(&quot;&#x2F;vote&quot;)public class VoteHandler &amp;#123;   @RequestMapping(value &#x3D; &quot;&#x2F;test01&quot;)   public String test01(@">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2024-03-14T06:26:00.000Z">
<meta property="article:modified_time" content="2024-03-14T06:42:47.557Z">
<meta property="article:author" content="Belly	|	vx：lin128Ve98">
<meta property="article:tag" content="SpirngMVC">
<meta name="twitter:card" content="summary"><title>SpringMVC笔记 | 码农呆的奋斗史</title><link ref="canonical" href="http://shuaidaia.gitee.io/2024/03/14/SpringMVC%E7%AC%94%E8%AE%B0/"><link rel="dns-prefetch" href="https://cdn.jsdelivr.net"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.12.1/css/all.min.css" type="text/css"><link rel="stylesheet" href="/css/index.css?v=2.8.0"><link rel="stylesheet" href="css/custom.css"><script>var Stun = window.Stun || {};
var CONFIG = {
  root: '/',
  algolia: undefined,
  assistSearch: undefined,
  fontIcon: {"prompt":{"success":"fas fa-check-circle","info":"fas fa-arrow-circle-right","warning":"fas fa-exclamation-circle","error":"fas fa-times-circle"},"copyBtn":"fas fa-copy"},
  sidebar: {"offsetTop":"20px","tocMaxDepth":6},
  header: {"enable":true,"showOnPost":true,"scrollDownIcon":false},
  postWidget: {"endText":true},
  nightMode: {"enable":true},
  back2top: {"enable":true},
  codeblock: {"style":"default","highlight":"light","wordWrap":false},
  reward: false,
  fancybox: false,
  zoomImage: {"gapAside":"20px"},
  galleryWaterfall: undefined,
  lazyload: false,
  pjax: undefined,
  externalLink: {"icon":{"enable":true,"name":"fas fa-external-link-alt"}},
  shortcuts: undefined,
  prompt: {"copyButton":"复制","copySuccess":"复制成功","copyError":"复制失败"},
  sourcePath: {"js":"js","css":"css","images":"images"},
};

window.CONFIG = CONFIG;</script><meta name="generator" content="Hexo 6.3.0"></head><body><div class="container" id="container"><header class="header" id="header"><div class="header-inner"><nav class="header-nav header-nav--fixed"><div class="header-nav-inner"><div class="header-nav-menubtn"><i class="fas fa-bars"></i></div><div class="header-nav-menu"><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/"><span class="header-nav-menu-item__icon"><i class="fas fa-home"></i></span><span class="header-nav-menu-item__text">首页</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/archives/"><span class="header-nav-menu-item__icon"><i class="fas fa-folder-open"></i></span><span class="header-nav-menu-item__text">归档</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/categories/"><span class="header-nav-menu-item__icon"><i class="fas fa-layer-group"></i></span><span class="header-nav-menu-item__text">分类</span></a></div><div class="header-nav-menu-item"><a class="header-nav-menu-item__link" href="/tags/"><span class="header-nav-menu-item__icon"><i class="fas fa-tags"></i></span><span class="header-nav-menu-item__text">标签</span></a></div></div><div class="header-nav-mode"><div class="mode"><div class="mode-track"><span class="mode-track-moon"></span><span class="mode-track-sun"></span></div><div class="mode-thumb"></div></div></div></div></nav><div class="header-banner"><div class="header-banner-info"><div class="header-banner-info__subtitle">总有人间一两风，填我十万八千梦。</div></div></div></div></header><main class="main" id="main"><div class="main-inner"><div class="content-wrap" id="content-wrap"><div class="content" id="content"><!-- Just used to judge whether it is an article page--><div id="is-post"></div><div class="post"><header class="post-header"><h1 class="post-title">SpringMVC笔记</h1><div class="post-meta"><span class="post-meta-item post-meta-item--createtime"><span class="post-meta-item__icon"><i class="far fa-calendar-plus"></i></span><span class="post-meta-item__info">发表于</span><span class="post-meta-item__value">2024-03-14</span></span><span class="post-meta-item post-meta-item--updatetime"><span class="post-meta-item__icon"><i class="far fa-calendar-check"></i></span><span class="post-meta-item__info">更新于</span><span class="post-meta-item__value">2024-03-14</span></span></div></header><div class="post-body">
        <h2 id="RequestParam注解："   >
          <a href="#RequestParam注解：" class="heading-link"><i class="fas fa-link"></i></a><a href="#RequestParam注解：" class="headerlink" title="@RequestParam注解："></a>@RequestParam注解：</h2>
      <figure class="highlight java"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Controller</span></span><br><span class="line"><span class="meta">@RequestMapping(&quot;/vote&quot;)</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">VoteHandler</span> &#123;</span><br><span class="line">   <span class="meta">@RequestMapping(value = &quot;/test01&quot;)</span></span><br><span class="line">   <span class="keyword">public</span> String <span class="title function_">test01</span><span class="params">(<span class="meta">@RequestParam(value = &quot;name&quot;, required = false)</span> String username)</span>&#123;</span><br><span class="line">        System.out.println(<span class="string">&quot;username= &quot;</span> + username);</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;success&quot;</span>;</span><br><span class="line">   &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></div></figure>


        <h4 id="RequestParam-value-x3D-“name”-required-x3D-false-注解说明："   >
          <a href="#RequestParam-value-x3D-“name”-required-x3D-false-注解说明：" class="heading-link"><i class="fas fa-link"></i></a><a href="#RequestParam-value-x3D-“name”-required-x3D-false-注解说明：" class="headerlink" title="@RequestParam(value &#x3D; “name”, required &#x3D; false)注解说明："></a>@RequestParam(value &#x3D; “name”, required &#x3D; false)注解说明：</h4>
      <p>1.获取到超链接传递的数据，请求<span class="exturl"><a class="exturl__link"   target="_blank" rel="noopener" href="http://localhost:8080/springmvc/vote/test01?name=xx" >http://localhost:8080/springmvc/vote/test01?name=xx</a><span class="exturl__icon"><i class="fas fa-external-link-alt"></i></span></span><br>2.@RequestParam 表示会接收提交的参数<br>3.value &#x3D; “name” 表示提交的参数名为name<br>4.required &#x3D; false 表示该参数可以没有，默认是ture，表示必须要传这个参数<br>5.当我使用@RequestParam(value &#x3D; “name”, required &#x3D; false)后就可以让请求的的参数名和方法的形参名可以不一致</p>

        <h2 id="ModelAttribute注解："   >
          <a href="#ModelAttribute注解：" class="heading-link"><i class="fas fa-link"></i></a><a href="#ModelAttribute注解：" class="headerlink" title="@ModelAttribute注解："></a>@ModelAttribute注解：</h2>
      <figure class="highlight java"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@Controller</span></span><br><span class="line"><span class="meta">@RequestMapping(&quot;/vote&quot;)</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">VoteHandler</span> &#123;</span><br><span class="line">	<span class="meta">@ModelAttribute</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">prepareModel</span><span class="params">()</span>&#123;</span><br><span class="line">        System.out.println(<span class="string">&quot;——————prepareModel()完成准备工作——————&quot;</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></div></figure>

<p>1.当VoteHandler的方法被标识@ModelAttribute就视为一个前置方法<br>2.当调用该VoteHandler类的其他的方法时，都会先执行该前置方法<br>3.类似AOP的前置通知<br>4.prepareModel前置方法，会切入到其他方法前执行<br>5.该用法一般用在用户管理</p>

        <h2 id="InitBinder注解："   >
          <a href="#InitBinder注解：" class="heading-link"><i class="fas fa-link"></i></a><a href="#InitBinder注解：" class="headerlink" title="@InitBinder注解："></a>@InitBinder注解：</h2>
      <figure class="highlight java"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@InitBinder</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title function_">initBinder</span><span class="params">(WebDataBinder webDataBinder)</span>&#123;</span><br><span class="line">    webDataBinder.setDisallowedFields(<span class="string">&quot;birthday&quot;</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></div></figure>

<p>1.方法上需要标注@InitBinder springmvc底层会初始化WebDataBinder<br>2.调用webDataBinder.setDisallowedFields(“birthday”);表示取消指定属性的绑定即：当表单提交字段为birthday时，<br>就不会把接收到的birthday值填充到model数据good的birthday属性中<br>3.机制：springmvc在底层通过反射调用目标方法时，接收到http请求的参数和值，使用反射+注解技术，取消对指定属性的填充<br>4.setDisallowedFields支持可变参数，可以填写多个字段<br>5.如果取消某个属性绑定，验证就没意义了，应当把验证的@NotEmpty注解去掉，birthday属性会使用默认值null</p>

        <h2 id="参数封装："   >
          <a href="#参数封装：" class="heading-link"><i class="fas fa-link"></i></a><a href="#参数封装：" class="headerlink" title="参数封装："></a>参数封装：</h2>
      
        <h4 id="1"   >
          <a href="#1" class="heading-link"><i class="fas fa-link"></i></a><a href="#1" class="headerlink" title="1."></a>1.</h4>
      <figure class="highlight java"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@PostMapping(&quot;/test03&quot;)</span></span><br><span class="line"><span class="keyword">public</span> String <span class="title function_">test03</span><span class="params">(Master master)</span>&#123;</span><br><span class="line">    System.out.println(<span class="string">&quot;master=&quot;</span> + master);</span><br><span class="line">    <span class="keyword">return</span> <span class="string">&quot;success&quot;</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></div></figure>

<p>获取提交的数据 -&gt; 封装成java对象<br>1.方法的形参用对应的类型来指定即可，SpringMVC会自动的进行封装<br>2.如果自动的完成封装，要求提交的数据，参数名和对象的字段名保持一致<br>3.如果属性是对象，这里仍然是通过 字段名.字段名<br>4.如果提交的数据的参数名和对象的字段名不匹配，则对象的属性值就是null<br>5.该封装底层是反射+注解..来实现</p>

        <h4 id="2"   >
          <a href="#2" class="heading-link"><i class="fas fa-link"></i></a><a href="#2" class="headerlink" title="2."></a>2.</h4>
      <figure class="highlight java"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@RequestMapping(&quot;/test06&quot;)</span></span><br><span class="line"><span class="keyword">public</span> String <span class="title function_">test06</span><span class="params">(Master master, Map&lt;String, Object&gt; map)</span>&#123;</span><br><span class="line">    map.put(<span class="string">&quot;address&quot;</span>, <span class="string">&quot;beijing&quot;</span>);</span><br><span class="line">    map.put(<span class="string">&quot;master&quot;</span>, <span class="literal">null</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="string">&quot;success&quot;</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></div></figure>

<p>1.通过Map&lt;String, Object&gt;设置数据到request域<br>2.通过map对象，添加属性到request中<br>3.原理分析：springmvc会遍历map，然后将map的k-v，存放到request域中</p>

        <h2 id="文件上传和下载："   >
          <a href="#文件上传和下载：" class="heading-link"><i class="fas fa-link"></i></a><a href="#文件上传和下载：" class="headerlink" title="文件上传和下载："></a>文件上传和下载：</h2>
      
        <h4 id="1-文件上传："   >
          <a href="#1-文件上传：" class="heading-link"><i class="fas fa-link"></i></a><a href="#1-文件上传：" class="headerlink" title="1.文件上传："></a>1.文件上传：</h4>
      <figure class="highlight java"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@RequestMapping(value = &quot;/upload&quot;)</span></span><br><span class="line"><span class="meta">@Controller</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">UploadFileHandler</span> &#123;</span><br><span class="line">    <span class="meta">@RequestMapping(&quot;/fileUpload&quot;)</span></span><br><span class="line">    <span class="keyword">public</span> String <span class="title function_">fileUpload</span><span class="params">(<span class="meta">@RequestParam(value = &quot;file&quot;)</span> MultipartFile file,</span></span><br><span class="line"><span class="params">                             HttpServletRequest request,</span></span><br><span class="line"><span class="params">                             String introduceName)</span> <span class="keyword">throws</span> IOException &#123;</span><br><span class="line"></span><br><span class="line">        <span class="comment">//接收到提交得文件名</span></span><br><span class="line">        <span class="type">String</span> <span class="variable">originalFilename</span> <span class="operator">=</span> file.getOriginalFilename();</span><br><span class="line">        System.out.println(<span class="string">&quot;上传得文件名：&quot;</span> + originalFilename);</span><br><span class="line">        System.out.println(<span class="string">&quot;上传得文件介绍：&quot;</span> + introduceName);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//得到要把上传文件保存到真正运行得那个路径[全路径包括文件名]</span></span><br><span class="line">        <span class="type">String</span> <span class="variable">fileFullPath</span> <span class="operator">=</span></span><br><span class="line">                request.getServletContext().getRealPath(<span class="string">&quot;/img/&quot;</span> + originalFilename);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//创建文件</span></span><br><span class="line">        <span class="type">File</span> <span class="variable">saveToFile</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">File</span>(fileFullPath);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//将上传得文件，转存到saveToFile文件里</span></span><br><span class="line">        file.transferTo(saveToFile);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//返回到成功页面</span></span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;success&quot;</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></div></figure>


        <h4 id="文件下载："   >
          <a href="#文件下载：" class="heading-link"><i class="fas fa-link"></i></a><a href="#文件下载：" class="headerlink" title="文件下载："></a>文件下载：</h4>
      <figure class="highlight java"><div class="table-container"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">@RequestMapping(&quot;/down&quot;)</span></span><br><span class="line"><span class="meta">@Controller</span></span><br><span class="line"><span class="keyword">public</span> <span class="keyword">class</span> <span class="title class_">DownFileHandler</span> &#123;</span><br><span class="line"></span><br><span class="line">    <span class="comment">//响应用户下载文件的请求</span></span><br><span class="line">    <span class="meta">@RequestMapping(&quot;/downFile&quot;)</span></span><br><span class="line">    <span class="keyword">public</span> ResponseEntity&lt;<span class="type">byte</span>[]&gt; downFile(HttpSession session) <span class="keyword">throws</span> IOException &#123;</span><br><span class="line"></span><br><span class="line">        <span class="comment">//1.先获取到下载文件的InputStream流</span></span><br><span class="line">        <span class="type">InputStream</span> <span class="variable">resourceAsStream</span> <span class="operator">=</span></span><br><span class="line">                session.getServletContext().getResourceAsStream(<span class="string">&quot;/img/copy.jpg&quot;</span>);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//2.开辟一个存放文件的byte数组，这里使用byte[]是库支持二进制数据</span></span><br><span class="line">        <span class="type">byte</span>[] bytes = <span class="keyword">new</span> <span class="title class_">byte</span>[resourceAsStream.available()];</span><br><span class="line"></span><br><span class="line">        <span class="comment">//3.将下载文件的数据，读入到byte[]</span></span><br><span class="line">        resourceAsStream.read(bytes);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//public ResponseEntity(@Nullable T body, @Nullable MultiValueMap&lt;String, String&gt; headers, HttpStatus status) &#123;&#125;</span></span><br><span class="line">        <span class="comment">//要返回的对象要三个参数 1.要下载的文件数据 2.http响应状态 3.http响应头headers</span></span><br><span class="line"></span><br><span class="line">        <span class="comment">//4.创建返回HttpStatus</span></span><br><span class="line">        <span class="type">HttpStatus</span> <span class="variable">httpStatus</span> <span class="operator">=</span> HttpStatus.OK;</span><br><span class="line"></span><br><span class="line">        <span class="comment">//5.创建headers</span></span><br><span class="line">        <span class="type">HttpHeaders</span> <span class="variable">httpHeaders</span> <span class="operator">=</span> <span class="keyword">new</span> <span class="title class_">HttpHeaders</span>();</span><br><span class="line">        <span class="comment">//指定返回的数据，客户端应当以附件形式处理</span></span><br><span class="line">        httpHeaders.add(<span class="string">&quot;Content-Disposition&quot;</span>, <span class="string">&quot;attachment;filename=copy.jpg&quot;</span>);</span><br><span class="line"></span><br><span class="line">        <span class="comment">//构建一个ResponseEntity对象放入需要的参数</span></span><br><span class="line">        ResponseEntity&lt;<span class="type">byte</span>[]&gt; responseEntity =</span><br><span class="line">                <span class="keyword">new</span> <span class="title class_">ResponseEntity</span>&lt;<span class="type">byte</span>[]&gt;(bytes, httpHeaders, httpStatus);</span><br><span class="line">        <span class="keyword">return</span> responseEntity;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></div></figure></div><footer class="post-footer"><div class="post-ending ending"><div class="ending__text">------ 本文结束，感谢您的阅读 ------</div></div><div class="post-copyright copyright"><div class="copyright-author"><span class="copyright-author__name">本文作者: </span><span class="copyright-author__value"><a href="http://shuaidaia.gitee.io">Belly	|	vx：lin128Ve98</a></span></div><div class="copyright-link"><span class="copyright-link__name">本文链接: </span><span class="copyright-link__value"><a href="http://shuaidaia.gitee.io/2024/03/14/SpringMVC%E7%AC%94%E8%AE%B0/">http://shuaidaia.gitee.io/2024/03/14/SpringMVC%E7%AC%94%E8%AE%B0/</a></span></div><div class="copyright-notice"><span class="copyright-notice__name">版权声明: </span><span class="copyright-notice__value">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en" rel="external nofollow" target="_blank">BY-NC-SA</a> 许可协议。转载请注明出处！</span></div></div><div class="post-tags"><span class="post-tags-item"><span class="post-tags-item__icon"><i class="fas fa-tag"></i></span><a class="post-tags-item__link" href="http://shuaidaia.gitee.io/tags/SpirngMVC/">SpirngMVC</a></span></div><nav class="post-paginator paginator"><div class="paginator-prev"><a class="paginator-prev__link" href="/2024/03/14/Spring%E7%AC%94%E8%AE%B0/"><span class="paginator-prev__icon"><i class="fas fa-angle-left"></i></span><span class="paginator-prev__text">Spring笔记</span></a></div><div class="paginator-next"><a class="paginator-next__link" href="/2024/02/27/%E4%B8%80%E4%BA%8C%E6%9C%88%E6%80%BB%E7%BB%93/"><span class="paginator-prev__text">一月和二月总结</span><span class="paginator-next__icon"><i class="fas fa-angle-right"></i></span></a></div></nav></footer></div></div></div><div class="sidebar-wrap" id="sidebar-wrap"><aside class="sidebar" id="sidebar"><div class="sidebar-nav"><span class="sidebar-nav-toc current">文章目录</span><span class="sidebar-nav-ov">站点概览</span></div><section class="sidebar-toc"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#RequestParam%E6%B3%A8%E8%A7%A3%EF%BC%9A"><span class="toc-number">1.</span> <span class="toc-text">
          @RequestParam注解：</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#RequestParam-value-x3D-%E2%80%9Cname%E2%80%9D-required-x3D-false-%E6%B3%A8%E8%A7%A3%E8%AF%B4%E6%98%8E%EF%BC%9A"><span class="toc-number">1.0.1.</span> <span class="toc-text">
          @RequestParam(value &#x3D; “name”, required &#x3D; false)注解说明：</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#ModelAttribute%E6%B3%A8%E8%A7%A3%EF%BC%9A"><span class="toc-number">2.</span> <span class="toc-text">
          @ModelAttribute注解：</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#InitBinder%E6%B3%A8%E8%A7%A3%EF%BC%9A"><span class="toc-number">3.</span> <span class="toc-text">
          @InitBinder注解：</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E6%95%B0%E5%B0%81%E8%A3%85%EF%BC%9A"><span class="toc-number">4.</span> <span class="toc-text">
          参数封装：</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1"><span class="toc-number">4.0.1.</span> <span class="toc-text">
          1.</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2"><span class="toc-number">4.0.2.</span> <span class="toc-text">
          2.</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E5%92%8C%E4%B8%8B%E8%BD%BD%EF%BC%9A"><span class="toc-number">5.</span> <span class="toc-text">
          文件上传和下载：</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%EF%BC%9A"><span class="toc-number">5.0.1.</span> <span class="toc-text">
          1.文件上传：</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%96%87%E4%BB%B6%E4%B8%8B%E8%BD%BD%EF%BC%9A"><span class="toc-number">5.0.2.</span> <span class="toc-text">
          文件下载：</span></a></li></ol></li></ol></li></ol></section><!-- ov = overview--><section class="sidebar-ov hide"><div class="sidebar-ov-author"><div class="sidebar-ov-author__avatar"><img class="sidebar-ov-author__avatar_img" src="/pho/IMG_0744(20220413-103811).JPG" alt="avatar"></div><p class="sidebar-ov-author__text">时时勤拂拭，勿使惹尘埃。</p></div><div class="sidebar-ov-state"><a class="sidebar-ov-state-item sidebar-ov-state-item--posts" href="/archives/"><div class="sidebar-ov-state-item__count">19</div><div class="sidebar-ov-state-item__name">归档</div></a><a class="sidebar-ov-state-item sidebar-ov-state-item--categories" href="/categories/"><div class="sidebar-ov-state-item__count">5</div><div class="sidebar-ov-state-item__name">分类</div></a><a class="sidebar-ov-state-item sidebar-ov-state-item--tags" href="/tags/"><div class="sidebar-ov-state-item__count">17</div><div class="sidebar-ov-state-item__name">标签</div></a></div><div class="sidebar-ov-cc"><a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en" target="_blank" rel="noopener" data-popover="知识共享许可协议" data-popover-pos="up"><img src="/images/cc-by-nc-sa.svg"></a></div></section><div class="sidebar-reading"><div class="sidebar-reading-info"><span class="sidebar-reading-info__text">你已阅读了 </span><span class="sidebar-reading-info__num">0</span><span class="sidebar-reading-info__perc">%</span></div><div class="sidebar-reading-line"></div></div></aside></div><div class="clearfix"></div></div></main><footer class="footer" id="footer"><div class="footer-inner"><div><span>Copyright © 2024</span><span class="footer__icon"><i class="fas fa-heart"></i></span><span>Belly	|	vx：lin128Ve98</span></div></div></footer><div class="loading-bar" id="loading-bar"><div class="loading-bar__progress"></div></div><div class="back2top" id="back2top"><span class="back2top__icon"><i class="fas fa-rocket"></i></span></div></div><script src="https://cdn.jsdelivr.net/npm/jquery@v3.4.1/dist/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@1.5.2/velocity.min.js"></script><script src="https://cdn.jsdelivr.net/npm/velocity-animate@1.5.2/velocity.ui.min.js"></script><script src="/js/utils.js?v=2.8.0"></script><script src="/js/stun-boot.js?v=2.8.0"></script><script src="/js/scroll.js?v=2.8.0"></script><script src="/js/header.js?v=2.8.0"></script><script src="/js/sidebar.js?v=2.8.0"></script></body></html>